
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1.3UI事件传递与响应 · zhoufei-iosknowledges</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhoufei">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="tuxiangxianshi.html" />
    
    
    <link rel="prev" href="shujutongbu.html" />
    

    
        <link rel="shortcut icon" href='../../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../../source/images/apple-touch-icon.jpg'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../../source/images/apple-touch-icon.jpg">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../../source/images/apple-touch-icon.jpg">
        
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"zhou415770319","repo":"iosKnowledges","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.feiyum.cn/index/" target="_blank" class="custom-link">我的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    iOS面试题总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="ui.html">
            
                <a href="ui.html">
            
                    
                    1、UI视图相关面试题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="UITableview.html">
            
                <a href="UITableview.html">
            
                    
                    1.1UITableview相关面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="shujutongbu.html">
            
                <a href="shujutongbu.html">
            
                    
                    1.2数据源同步
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.3" data-path="shijianchuandi.html">
            
                <a href="shijianchuandi.html">
            
                    
                    1.3UI事件传递与响应
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="tuxiangxianshi.html">
            
                <a href="tuxiangxianshi.html">
            
                    
                    1.4UI图像显示原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="kadundiaozheng.html">
            
                <a href="kadundiaozheng.html">
            
                    
                    1.5UI卡顿掉帧原因
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="yibuhuizhi.html">
            
                <a href="yibuhuizhi.html">
            
                    
                    1.6异步绘制原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="lipingxuanran.html">
            
                <a href="lipingxuanran.html">
            
                    
                    1.7离屏渲染
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../oc/2.html">
            
                <a href="../oc/2.html">
            
                    
                    2、OC语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../oc/2.1.html">
            
                <a href="../oc/2.1.html">
            
                    
                    2.1OC相关面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../oc/2.2.html">
            
                <a href="../oc/2.2.html">
            
                    
                    2.2分类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../oc/2_4.html">
            
                <a href="../oc/2_4.html">
            
                    
                    2.4扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../oc/2.5.html">
            
                <a href="../oc/2.5.html">
            
                    
                    2.5代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../oc/2.6.html">
            
                <a href="../oc/2.6.html">
            
                    
                    2.6通知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../oc/2.7.html">
            
                <a href="../oc/2.7.html">
            
                    
                    2.7KVO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../oc/2.8.html">
            
                <a href="../oc/2.8.html">
            
                    
                    2.8KVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../oc/2.9.html">
            
                <a href="../oc/2.9.html">
            
                    
                    2.9属性关键字
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../runtime/3.html">
            
                <a href="../runtime/3.html">
            
                    
                    3、Runtime
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../runtime/3.1.html">
            
                <a href="../runtime/3.1.html">
            
                    
                    3.1对象、类对象、元类对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../runtime/3.2.html">
            
                <a href="../runtime/3.2.html">
            
                    
                    3.2消息传递机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../runtime/3.3.html">
            
                <a href="../runtime/3.3.html">
            
                    
                    3.3消息转发流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../runtime/3.4.html">
            
                <a href="../runtime/3.4.html">
            
                    
                    3.4Method-Swizzling
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../neicun/4.html">
            
                <a href="../neicun/4.html">
            
                    
                    4、内存
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../neicun/4.1.html">
            
                <a href="../neicun/4.1.html">
            
                    
                    4.1引用计数表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../neicun/4.2.html">
            
                <a href="../neicun/4.2.html">
            
                    
                    4.2弱引用表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../neicun/4.3.html">
            
                <a href="../neicun/4.3.html">
            
                    
                    4.3ARC、MRC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../neicun/4.4.html">
            
                <a href="../neicun/4.4.html">
            
                    
                    4.4循环引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../neicun/4.5.html">
            
                <a href="../neicun/4.5.html">
            
                    
                    4.5内存管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../block/5.html">
            
                <a href="../block/5.html">
            
                    
                    5、Block
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../block/5.1.html">
            
                <a href="../block/5.1.html">
            
                    
                    5.1Block本质
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../block/5.2.html">
            
                <a href="../block/5.2.html">
            
                    
                    5.2截获变量特性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../block/5.3.html">
            
                <a href="../block/5.3.html">
            
                    
                    5.3内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../block/5.4.html">
            
                <a href="../block/5.4.html">
            
                    
                    5.4循环引用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../duoxiancheng/6.html">
            
                <a href="../duoxiancheng/6.html">
            
                    
                    6、多线程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../duoxiancheng/6.1.html">
            
                <a href="../duoxiancheng/6.1.html">
            
                    
                    6.1GCD、nsoperation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../duoxiancheng/6.2.html">
            
                <a href="../duoxiancheng/6.2.html">
            
                    
                    6.2资源共享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../duoxiancheng/6.3.html">
            
                <a href="../duoxiancheng/6.3.html">
            
                    
                    6.3线程同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../duoxiancheng/6.4.html">
            
                <a href="../duoxiancheng/6.4.html">
            
                    
                    6.4SpinLock等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../runloop/7.md">
            
                <span>
            
                    
                    7、RunLoop
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../runloop/7.1.md">
            
                <span>
            
                    
                    7.1事件循环
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../runloop/7.2.md">
            
                <span>
            
                    
                    7.2用户态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../runloop/7.3.md">
            
                <span>
            
                    
                    7.3核心态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../runloop/7.4.md">
            
                <span>
            
                    
                    7.4常驻线程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../network/8.md">
            
                <span>
            
                    
                    8、网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../network/8.1.md">
            
                <span>
            
                    
                    8.1HTTPS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../network/8.2.md">
            
                <span>
            
                    
                    8.2对称加密算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../network/8.3.md">
            
                <span>
            
                    
                    8.3非对称加密
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../network/8.4.md">
            
                <span>
            
                    
                    8.4DNS解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../network/8.5.md">
            
                <span>
            
                    
                    8.5HTTP、TCP
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >1.3UI事件传递与响应</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#131uiview&#x548C;calayer"><b></b>1.3.1UIView&#x548C;CALayer</a></li><li><span class="title-icon "></span><a href="#132&#x4E8B;&#x4EF6;&#x4F20;&#x9012;"><b></b>1.3.2&#x4E8B;&#x4EF6;&#x4F20;&#x9012;</a></li><li><span class="title-icon "></span><a href="#133&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;"><b></b>1.3.3&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="131uiview&#x548C;calayer"><a name="131uiview&#x548C;calayer" class="anchor-navigation-ex-anchor" href="#131uiview&#x548C;calayer"><i class="fa fa-link" aria-hidden="true"></i></a><a name="131uiview&#x548C;calayer" class="plugin-anchor" href="#131uiview&#x548C;calayer"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1UIView&#x548C;CALayer</h3>
<p>UIView&#x663E;&#x793A;&#x5728;&#x5C4F;&#x5E55;&#x4E0A;&#x5F52;&#x529F;&#x4E8E;CALayer&#xFF0C;&#x901A;&#x8FC7;&#x8C03;&#x7528;drawRect&#x65B9;&#x6CD5;&#x6765;&#x6E32;&#x67D3;&#x81EA;&#x8EAB;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x8C03;&#x8282;CALayer&#x5C5E;&#x6027;&#x53EF;&#x4EE5;&#x8C03;&#x6574;UIView&#x7684;&#x5916;&#x89C2;&#xFF0C;UIView&#x7EE7;&#x627F;&#x81EA;UIResponder&#xFF0C;&#x6BD4;&#x8D77;CALayer&#x53EF;&#x4EE5;&#x54CD;&#x5E94;&#x7528;&#x6237;&#x4E8B;&#x4EF6;&#xFF0C;Xcode6&#x4E4B;&#x540E;&#x53EF;&#x4EE5;&#x65B9;&#x4FBF;&#x7684;&#x901A;&#x8FC7;&#x89C6;&#x56FE;&#x8C03;&#x8BD5;&#x529F;&#x80FD;&#x67E5;&#x770B;&#x56FE;&#x5C42;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;</p>
<p>UIView&#x662F;iOS&#x7CFB;&#x7EDF;&#x4E2D;&#x754C;&#x9762;&#x5143;&#x7D20;&#x7684;&#x57FA;&#x7840;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x754C;&#x9762;&#x5143;&#x7D20;&#x90FD;&#x7EE7;&#x627F;&#x81EA;&#x5B83;&#x3002;&#x5B83;&#x5185;&#x90E8;&#x662F;&#x7531;Core Animation&#x6765;&#x5B9E;&#x73B0;&#x7684;&#xFF0C;&#x5B83;&#x771F;&#x6B63;&#x7684;&#x7ED8;&#x56FE;&#x90E8;&#x5206;&#xFF0C;&#x662F;&#x7531;&#x4E00;&#x4E2A;&#x53EB;CALayer(Core Animation Layer)&#x7684;&#x7C7B;&#x6765;&#x7BA1;&#x7406;&#x3002;UIView&#x672C;&#x8EAB;&#xFF0C;&#x66F4;&#x50CF;&#x662F;&#x4E00;&#x4E2A;CALayer&#x7684;&#x7BA1;&#x7406;&#x5668;&#xFF0C;&#x8BBF;&#x95EE;&#x5B83;&#x7684;&#x8DDF;&#x7ED8;&#x56FE;&#x548C;&#x5750;&#x6807;&#x6709;&#x5173;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x5982;frame&#xFF0C;bounds&#x7B49;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x5185;&#x90E8;&#x90FD;&#x662F;&#x8BBF;&#x95EE;&#x5B83;&#x6240;&#x5728;CALayer&#x7684;&#x76F8;&#x5173;&#x5C5E;&#x6027;</p>
<p>UIView&#x6709;&#x4E2A;layer&#x5C5E;&#x6027;&#xFF0C;&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;&#x5B83;&#x7684;&#x4E3B;CALayer&#x5B9E;&#x4F8B;&#xFF0C;UIView&#x6709;&#x4E00;&#x4E2A;layerClass&#x65B9;&#x6CD5;&#xFF0C;&#x8FD4;&#x56DE;&#x4E3B;layer&#x6240;&#x4F7F;&#x7528;&#x7684;&#x7C7B;&#xFF0C;UIView&#x7684;&#x5B50;&#x7C7B;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x91CD;&#x8F7D;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x6765;&#x8BA9;UIView&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;CALayer&#x6765;&#x663E;&#x793A;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre><code class="lang-objective-c">- (class) layerClass {
    // &#x4F7F;&#x67D0;&#x4E2A;UIView&#x7684;&#x5B50;&#x7C7B;&#x4F7F;&#x7528;GL&#x6765;&#x8FDB;&#x884C;&#x7ED8;&#x5236;
    return ([CAEAGLLayer class]);
}
</code></pre>
<p>UIView&#x7684;CALayer&#x7C7B;&#x4F3C;UIView&#x7684;&#x5B50;View&#x6811;&#x5F62;&#x7ED3;&#x6784;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5411;&#x5B83;&#x7684;layer&#x4E0A;&#x6DFB;&#x52A0;&#x5B50;layer&#xFF0C;&#x6765;&#x5B8C;&#x6210;&#x67D0;&#x4E9B;&#x7279;&#x6B8A;&#x7684;&#x663E;&#x793A;&#x3002;&#x4F8B;&#x5982;&#x4E0B;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x4F1A;&#x5728;&#x76EE;&#x6807;View&#x4E0A;&#x6577;&#x4E0A;&#x4E00;&#x5C42;&#x9ED1;&#x8272;&#x7684;&#x900F;&#x660E;&#x8584;&#x819C;&#x3002;</p>
<pre><code class="lang-objective-c">grayCover = [[CALayer alloc]init];
grayCover.backgroudColor = [[UIColor blackColor]colorWithAlphaComponent:0.2].CGColor;
[self.layer addSubLayer:grayCover];
</code></pre>
<p>&#x8865;&#x5145;&#x90E8;&#x5206;&#xFF0C;&#x8FD9;&#x90E8;&#x5206;&#x6709;&#x6DF1;&#x5EA6;&#x4E86;&#xFF0C;&#x5927;&#x81F4;&#x4E86;&#x89E3;&#x4E00;&#x4E0B;&#x5427;&#xFF0C;UIView&#x7684;layer&#x6811;&#x5F62;&#x5728;&#x7CFB;&#x7EDF;&#x5185;&#x90E8;&#x88AB;&#x7CFB;&#x7EDF;&#x7EF4;&#x62A4;&#x7740;&#x4E09;&#x4EFD;copy</p>
<p>&#x903B;&#x8F91;&#x6811;&#xFF0C;&#x5C31;&#x662F;&#x4EE3;&#x7801;&#x91CC;&#x53EF;&#x4EE5;&#x64CD;&#x7EB5;&#x7684;&#xFF0C;&#x4F8B;&#x5982;&#x66F4;&#x6539;layer&#x7684;&#x5C5E;&#x6027;&#x7B49;&#x7B49;&#x5C31;&#x5728;&#x8FD9;&#x4E00;&#x4EFD;</p>
<p>&#x52A8;&#x753B;&#x6811;&#xFF0C;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x4E2D;&#x95F4;&#x5C42;&#xFF0C;&#x7CFB;&#x7EDF;&#x6B63;&#x662F;&#x5728;&#x8FD9;&#x4E00;&#x5C42;&#x4E0A;&#x66F4;&#x6539;&#x5C5E;&#x6027;&#xFF0C;&#x8FDB;&#x884C;&#x5404;&#x79CD;&#x6E32;&#x67D3;&#x64CD;&#x4F5C;</p>
<p>&#x663E;&#x793A;&#x6811;&#xFF0C;&#x8FD9;&#x68F5;&#x6811;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x5F53;&#x524D;&#x6B63;&#x88AB;&#x663E;&#x793A;&#x5728;&#x5C4F;&#x5E55;&#x4E0A;&#x7684;&#x5185;&#x5BB9;</p>
<p>&#x8FD9;&#x4E09;&#x68F5;&#x6811;&#x7684;&#x903B;&#x8F91;&#x7ED3;&#x6784;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x533A;&#x522B;&#x53EA;&#x6709;&#x5404;&#x81EA;&#x7684;&#x5C5E;&#x6027;</p>
<h3 id="132&#x4E8B;&#x4EF6;&#x4F20;&#x9012;"><a name="132&#x4E8B;&#x4EF6;&#x4F20;&#x9012;" class="anchor-navigation-ex-anchor" href="#132&#x4E8B;&#x4EF6;&#x4F20;&#x9012;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="132&#x4E8B;&#x4EF6;&#x4F20;&#x9012;" class="plugin-anchor" href="#132&#x4E8B;&#x4EF6;&#x4F20;&#x9012;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.2&#x4E8B;&#x4EF6;&#x4F20;&#x9012;</h3>
<pre><code class="lang-objective-c">// &#x6B64;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x7684;View&#x662F;&#x672C;&#x6B21;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;&#x9700;&#x8981;&#x7684;&#x6700;&#x4F73;View
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

// &#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x70B9;&#x662F;&#x5426;&#x843D;&#x5728;&#x8303;&#x56F4;&#x5185;
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
</code></pre>
<p>1.&#x5F53;iOS&#x7A0B;&#x5E8F;&#x4E2D;&#x53D1;&#x751F;&#x89E6;&#x6478;&#x4E8B;&#x4EF6;&#x540E;&#xFF0C;&#x7CFB;&#x7EDF;&#x4F1A;&#x5C06;&#x4E8B;&#x4EF6;&#x52A0;&#x5165;&#x5230;UIApplication&#x7BA1;&#x7406;&#x7684;&#x4E00;&#x4E2A;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x4E2D;</p>
<p>2.UIApplication&#x5C06;&#x5904;&#x4E8E;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x6700;&#x524D;&#x7AEF;&#x7684;&#x4E8B;&#x4EF6;&#x5411;&#x4E0B;&#x5206;&#x53D1;&#x3002;&#x5373;UIWindow&#x3002;</p>
<p>3.UIWindow&#x5C06;&#x4E8B;&#x4EF6;&#x5411;&#x4E0B;&#x5206;&#x53D1;&#xFF0C;&#x5373;UIView&#x3002;</p>
<p>4.UIView&#x9996;&#x5148;&#x770B;&#x81EA;&#x5DF1;&#x662F;&#x5426;&#x80FD;&#x5904;&#x7406;&#x4E8B;&#x4EF6;&#xFF0C;&#x89E6;&#x6478;&#x70B9;&#x662F;&#x5426;&#x5728;&#x81EA;&#x5DF1;&#x8EAB;&#x4E0A;&#x3002;&#x5982;&#x679C;&#x80FD;&#xFF0C;&#x90A3;&#x4E48;&#x7EE7;&#x7EED;&#x5BFB;&#x627E;&#x5B50;&#x89C6;&#x56FE;&#x3002;</p>
<p>5.&#x904D;&#x5386;&#x5B50;&#x63A7;&#x4EF6;&#xFF0C;&#x91CD;&#x590D;&#x4EE5;&#x4E0A;&#x4E24;&#x6B65;&#x3002;</p>
<p>6.&#x5982;&#x679C;&#x6CA1;&#x6709;&#x627E;&#x5230;&#xFF0C;&#x90A3;&#x4E48;&#x81EA;&#x5DF1;&#x5C31;&#x662F;&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x8005;&#x3002;&#x5982;&#x679C;</p>
<p>7.&#x5982;&#x679C;&#x81EA;&#x5DF1;&#x4E0D;&#x80FD;&#x5904;&#x7406;&#xFF0C;&#x90A3;&#x4E48;&#x4E0D;&#x505A;&#x4EFB;&#x4F55;&#x5904;&#x7406;&#x3002;</p>
<p>&#x5176;&#x4E2D; UIView&#x4E0D;&#x63A5;&#x53D7;&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x7684;&#x60C5;&#x51B5;&#x4E3B;&#x8981;&#x6709;&#x4EE5;&#x4E0B;&#x4E09;&#x79CD;</p>
<p>1&#xFF09;alpha &lt;0.01</p>
<p>2)userInteractionEnabled = NO</p>
<p>3.hidden &#xFF1D; YES.</p>
<p>&#x8FD9;&#x4E2A;&#x4ECE;&#x7236;&#x63A7;&#x4EF6;&#x5230;&#x5B50;&#x63A7;&#x4EF6;&#x5BFB;&#x627E;&#x5904;&#x7406;&#x4E8B;&#x4EF6;&#x6700;&#x5408;&#x9002;&#x7684;view&#x7684;&#x8FC7;&#x7A0B;&#xFF0C;&#x5982;&#x679C;&#x7236;&#x89C6;&#x56FE;&#x4E0D;&#x63A5;&#x53D7;&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#xFF08;&#x4E0A;&#x9762;&#x4E09;&#x79CD;&#x60C5;&#x51B5;&#xFF09;&#xFF0C;&#x5219;&#x5B50;&#x89C6;&#x56FE;&#x4E5F;&#x4E0D;&#x80FD;&#x63A5;&#x6536;&#x4E8B;&#x4EF6;&#x3002;&#x4E8B;&#x4EF6;&#x53EA;&#x8981;&#x89E6;&#x6478;&#x4E86;&#x5C31;&#x4F1A;&#x4EA7;&#x751F;&#xFF0C;&#x5173;&#x952E;&#x5728;&#x4E8E;&#x662F;&#x5426;&#x6709;&#x6700;&#x5408;&#x9002;&#x7684;view&#x6765;&#x5904;&#x7406;&#x548C;&#x63A5;&#x6536;&#x4E8B;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x904D;&#x5386;&#x5230;&#x6700;&#x540E;&#x90FD;&#x6CA1;&#x6709;&#x6700;&#x5408;&#x9002;&#x7684;view&#x6765;&#x63A5;&#x6536;&#x4E8B;&#x4EF6;&#xFF0C;&#x5219;&#x8BE5;&#x4E8B;&#x4EF6;&#x88AB;&#x5E9F;&#x5F03;&#x3002;</p>
<p><a href="https://www.jianshu.com/p/410ca78faa98" title="iOS &#x54CD;&#x5E94;&#x94FE;&#x548C;&#x4E8B;&#x4EF6;&#x4F20;&#x9012;" target="_blank">iOS &#x54CD;&#x5E94;&#x94FE;&#x548C;&#x4E8B;&#x4EF6;&#x4F20;&#x9012;</a></p>
<p><img src="../../img/ui-5.png" alt=""></p>
<h3 id="133&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;"><a name="133&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;" class="anchor-navigation-ex-anchor" href="#133&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="133&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;" class="plugin-anchor" href="#133&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.3&#x89C6;&#x56FE;&#x4E8B;&#x4EF6;&#x54CD;&#x5E94;</h3>
<p><img src="../../img/ui-6.png" alt=""></p>
<pre><code class="lang-objective-c">    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
</code></pre>
<p><a href="https://www.jianshu.com/p/481465fc4f2d" title="&#x6D45;&#x8C08; iOS &#x4E8B;&#x4EF6;&#x7684;&#x4F20;&#x9012;&#x548C;&#x54CD;&#x5E94;&#x8FC7;&#x7A0B;" target="_blank">&#x6D45;&#x8C08; iOS &#x4E8B;&#x4EF6;&#x7684;&#x4F20;&#x9012;&#x548C;&#x54CD;&#x5E94;&#x8FC7;&#x7A0B;</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="shujutongbu.html" class="navigation navigation-prev " aria-label="Previous page: 1.2数据源同步">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="tuxiangxianshi.html" class="navigation navigation-next " aria-label="Next page: 1.4UI图像显示原理">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1.3UI事件传递与响应","level":"1.2.3","depth":2,"next":{"title":"1.4UI图像显示原理","level":"1.2.4","depth":2,"path":"md/ui/tuxiangxianshi.md","ref":"md/ui/tuxiangxianshi.md","articles":[]},"previous":{"title":"1.2数据源同步","level":"1.2.2","depth":2,"path":"md/ui/shujutongbu.md","ref":"md/ui/shujutongbu.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","github","github-buttons","donate","sharing-plus","anchor-navigation-ex","favicon","livereload"],"styles":{"website":"./styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"github":{"url":"https://github.com/zhou415770319"},"livereload":{},"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"../../img/alipay.JPG","alipayText":" ","button":"赞赏","title":"","wechat":"","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{"shortcut":"./source/images/favicon.jpg","bookmark":"./source/images/favicon.jpg","appleTouch":"./source/images/apple-touch-icon.jpg","appleTouchMore":{"120x120":"./source/images/apple-touch-icon.jpg","180x180":"./source/images/apple-touch-icon.jpg"}},"github-buttons":{"buttons":[{"user":"zhou415770319","repo":"iosKnowledges","type":"star","size":"small","count":true}]},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"theme":"default","author":"zhoufei","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"zhoufei-iosknowledges","language":"zh-hans","links":{"sidebar":{"我的博客":"http://www.feiyum.cn/index/"}},"gitbook":"3.2.3","description":"ios面试知识点总结"},"file":{"path":"md/ui/shijianchuandi.md","mtime":"2019-05-03T14:40:51.323Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-03T14:51:39.741Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

